<?php
	
	include "./db_conf.php";
	
	try{
	
		$dsn = "mysql:host=$db_host;dbname=$db_name";
	
		$pdo = new PDO($dsn,$db_user,$db_pass,array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
		
		$pdo->query("set names utf8");
		
		$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
		
	}catch(PDOException $e){
	
		exit($e->getMessage());
	
	}
	
	$sql = "select id,to_user,from_user,ptime,content from weixin";
	
	$stmt = $pdo->prepare($sql);
	
	$stmt->execute();
	
	$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
	
	if(!empty($data)){
	
		echo "<table border='1' width='700px'>";
		foreach($data as $val){
			
			echo "<tr>";
			echo "<td>".$val['id']."</td>";
			echo "<td>".$val['to_user']."</td>";
			echo "<td>".$val['from_user']."</td>";
			echo "<td>".$val['ptime']."</td>";
			echo "<td>".$val['content']."</td>";
			echo "</tr>";
		
		}
		echo "</table>";
	
	}